package com.yanliang.servlet;

import com.yanliang.model.Request;
import com.yanliang.model.Response;
import com.yanliang.utils.HttpProtocolUtil;

import java.io.IOException;

/**
 * @author yanliang
 * @date 5/10/20203:14 PM
 */
public class MyServlet extends HttpServlet {

	@Override
	public void doGet(Request request, Response response) {
		String content = "<h1>MyServlet get requesto</h1>";
		try {
			response.output((HttpProtocolUtil.getHttpHeader200(content.getBytes().length) + content));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	@Override
	public void doPost(Request request, Response response) {
		String content = "<h1>MyServlet post request</h1>";
		try {
			response.output((HttpProtocolUtil.getHttpHeader200(content.getBytes().length) + content));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	@Override
	public void init() throws Exception {

	}

	@Override
	public void destory() throws Exception {

	}
}
